package com.edu.service.impl;

import com.edu.bean.User;
import com.edu.mapper.UserMapper;
import com.edu.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author:zyn
 * @Date:2025/11/21--11:38:45
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;
    @Override
    public Map<String, Object> userLogin(String username, String password) {
        Map<String,Object> map=new HashMap<>();
        User user=userMapper.selectUserByUsernameAndPassword(username,password);
        if(user != null){
            map.put("loginUser",user);
        }else {
            user=userMapper.selectUserByName(username);
            if(user !=null){
                map.put("msg","密码错误");
            }else {
                map.put("msg","账号不存在");
            }
        }
        return map;
    }

    @Override
    public int addUser(User user) {
        return userMapper.insertUser(user);
    }
}
